﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using XNALibrary.Interfaces;
using XNALibrary.Effects;

namespace XNALibrary
{
    public class LightBulb :  RigidBody, IPointLight
    {
        private bool isOn;
        public bool IsOn
        {
            get
            {
                if (effect is LightBulbEffect)
                    return ((LightBulbEffect)effect).LightBulbOn;
                else
                    return isOn;
            }
            set
            {
                if (effect is LightBulbEffect)
                    ((LightBulbEffect)effect).LightBulbOn = value;
                else
                    isOn = value;
            }
        }

        private float intensity;
        private Color color;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="m"></param>
        /// <param name="pos"></param>
        /// <param name="orentaion">{yaw, pitch, roll} in degrees</param>
        public LightBulb(Model m, Vector3 pos, Vector3 orientation) : base(m ,pos ,orientation) 
        {
            color = Color.White;
            intensity = 2.0f;
            isOn = true;
        }

        public LightBulb(Model m, Vector3 pos, Vector3 orientation, float intens)
            : this(m, pos, orientation)
        {
            intensity = intens;
        }

        public LightBulb(Model m, Vector3 pos, Vector3 orientation, float intens, Color color)
            : this(m, pos, orientation, intens)
        {
            this.color = color;
        }

        #region IPointLight Members


        public float Intensity
        {
            get { return intensity; }
        }

        public Color Color
        {
            get { return color; }
            set 
            {
                color = value;
                if (effect is LightBulbEffect)
                    ((LightBulbEffect)effect).color = value;
            }
        }

        #endregion

        public override string ToString()
        {
            return color.ToString() + " LightBulb Position: " + Position.ToString();
        }
    }
}
